{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''  \n",
    "     此代码完成冒泡排序python 实现\n",
    "     author: fuhongyu\n",
    "     time: 2018年7月27日\n",
    "     时间复杂度： n^2\n",
    "     目标：5分钟写出来\n",
    "\n",
    "'''\n",
    "def bubblesort(lists):\n",
    "    for i in range(len(lists)-1):\n",
    "        for j in range(i+1 , len(lists)):\n",
    "            if lists[i] > lists[j]:\n",
    "                temp = lists[i]\n",
    "                lists[i] = lists[j]\n",
    "                lists[j] = temp\n",
    "    return lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 5, 6, 32, 36, 67]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lists = [5,32,67,1,36,6]\n",
    "bubblesort(lists)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
